<template>
	<section id="home_search">

		<!-- 搜索框 -->
		<van-search id="searchIpt" v-model="supValue" placeholder="请输入宝贝链接或名称" show-action @search="onSupSearch">
			<div slot="action" @click="onSupSearch">搜索</div>
		</van-search>

		<!-- 搜索列表 -->
		<van-card v-for='item in listMain' :price="item.zk_final_price" :desc="item.provcity" :title="item.title" :thumb="item.pict_url"
		 :thumb-link="item.item_url">
		 <div slot="footer">
			<van-button size="mini" @click="convertFunc(item.num_iid)">领券</van-button>
			<van-button size="mini">按钮</van-button>
		</div>
		</van-card>


	</section>
</template>

<script>
	export default {
		data() {
			return {
				supValue: '',
				listMain: [],
			};
		},
		components: {

		},
		methods: {
			onSupSearch() {
				let supValue = this.supValue;
				if (!supValue) {
					this.$toast('请输入正确内容');
					return false;
				}
				this.service.superSearch({
					q: supValue
				}).then(res => {
					if (res.code == 1) {
						let list = res.data;
						this.listMain = list.tbk_item_get_response.results.n_tbk_item;
					}
				})
			},
			convertFunc(num_iid){
				this.service.convert({
					num_iids: num_iid
				}).then(res => {
					if (res.code == 1) {
						console.log(res.data)
					}
				})
			},
			myFocus:function(){
				var idObj = document.getElementById('searchIpt');
				 idObj.focus();
		  }
		},
		mounted() {
			this.myFocus()
		},
		computed: {

		}



	};
</script>
<style scoped lang="scss">

</style>
